﻿var jzcode = {
    h5: {
        gtool: {
            // pos:{x,y}
            // size:{w,h}
            // targetX,
            // targetY
            containsPSXY: function (pos, size, targetX, targetY) {
                if (pos.x < targetX && pos.y < targetY
                    && pos.x + size.w > targetX
                    && pos.y + size.h > targetY) {
                    return true;
                }
                return false;
            },
            containsXYWHXY: function (x, y, w, h, targetX, targetY) {
                if (x < targetX && y < targetY
                    && x + w > targetX
                    && y + h > targetY) {
                    return true;
                }
                return false;
            },
            // 计算左上角的位置
            calcPosWHWH: function (alignH, alignV, contentW, contentH, containerW, containerH) {
                var x = 0;
                var y = 0;
                if (alignH == 'center') {
                    x = (containerW - contentW) / 2;
                }

                if (alignV == 'center') {
                    y = (containerH - contentH) / 2;
                }
                return { x: x, y: y };
            }
        },
        ui: {

        }
    },
    com: {
        //
        //
        // 
        // func(item, {index, length})
        foreach: function (array, func) {
            for (var index = 0; index < array.length; index++) {
                func(array[index], { index: index, length: array.length });
            }
        }
    },
    coolzon: {
        _nodeArr:[],
        run: function () {
        }
    },
    res: {
        _baseUrl:null,
        get: function (relativeUrl) {
            return getUrl(relativeUrl);
        },
        getUrl: function (relativeUrl) {
            if (this._baseUrl) {
                return this._baseUrl + relativeUrl;
            } else {
                return relativeUrl;
            }
        },
        setBaseUrl: function (baseUrl) {
            this._baseUrl = baseUrl;
        }
    },
    data: {
        _baseUrl:null,
        getUrl: function (relativeUrl) {
            if (this._baseUrl) {
                return this._baseUrl + relativeUrl;
            } else {
                return relativeUrl;
            }
        },
        setBaseUrl: function (baseUrl) {
            this._baseUrl = baseUrl;
        }
    }
};

function JzH5Node9(option) {
    this.option = option;
    this.render = function(){
    }
}